﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// 信息文档合发单位 逻辑类
    /// </summary>
    public class DocumentUnionPubEmpl
    {
        /// <summary>
        /// 信息文档合发单位数据类
        /// </summary>
        private DAL.DocumentUnionPubEmpl documentUnionPubEmplDAL = new DAL.DocumentUnionPubEmpl();
        /// <summary>
        /// 构造函数
        /// </summary>
        public DocumentUnionPubEmpl()
        {
        }
        /// <summary>
        /// 获得数据列表
        /// <creator>wangl</creator>
        /// <date>2013-08-16</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="docId">文档编号</param>
        /// <returns>合发部门列表</returns>
        public List<Model.DocumentUnionPubEmpl> GetModelList(string entityNo, decimal docId)
        {
            DataSet ds = documentUnionPubEmplDAL.GetModelList(entityNo, docId);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// <creator>wangl</creator>
        /// <date>2013-08-16</date>
        /// </summary>
        /// <param name="dt">DataTable对象</param> 
        /// <returns>合发部门列表</returns>
        private List<ElingOA6_Admin_DSJCJ.Model.DocumentUnionPubEmpl> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.DocumentUnionPubEmpl> modelList = new List<ElingOA6_Admin_DSJCJ.Model.DocumentUnionPubEmpl>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.DocumentUnionPubEmpl model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = documentUnionPubEmplDAL.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 合发数据根据FDocId,FDeptNo分组，用于查询某文档的所有部门编号
        /// <creator>sunlj</creator>
        /// <date>2013-10-16</date>
        /// </summary>
        public List<Model.DocumentUnionPubEmpl> GetModelList_DocIdAndDeptNo(string strWhere)
        {
            DataSet ds = documentUnionPubEmplDAL.GetList_DocIdAndDeptNo(strWhere);
            return DataTableToList2(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// <creator>sunlj</creator>
        /// <date>2013-10-16</date>
        /// </summary>
        public List<Model.DocumentUnionPubEmpl> DataTableToList2(DataTable dt)
        {
            List<Model.DocumentUnionPubEmpl> modelList = new List<Model.DocumentUnionPubEmpl>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.DocumentUnionPubEmpl model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = documentUnionPubEmplDAL.DataRowToModel2(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }


    }
}
